<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var $block \Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix */
?>
<?php
$productMatrix = $block->getProductMatrix();
$attributes = $block->getProductAttributes();
$currencySymbol = $block->getCurrencySymbol();
?>
<div class="<?= /* @noEscape */ $block->getData('config/dataScope') ?>" data-role="step-wizard-dialog" data-bind="scope: '<?= /* @noEscape */ $block->getForm() ?>.<?= /* @noEscape */ $block->getModal() ?>'">
    <!-- ko template: getTemplate() --><!-- /ko -->
</div>
<div class="<?= /* @noEscape */ $block->getData('config/dataScope') ?>" id="product-variations-matrix" data-role="product-variations-matrix">
    <div data-bind="scope: 'configurableVariations'"></div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "<?= /* @noEscape */ $block->getData('config/form') ?>.<?= /* @noEscape */ $block->getModal() ?>": {
                        "component": "Magento_ConfigurableProduct/js/components/modal-configurable",
                        "options": {"type": "slide", "title": "<?php echo $block->escapeHtml(__('Create Product Configurations')); ?>"},
                        "formName": "<?= /* @noEscape */ $block->getForm() ?>",
                        "isTemplate": false,
                        "stepWizard": "<?= /* @noEscape */ $block->getData('config/nameStepWizard') ?>",
                        "children": {
                            "wizard": {
                                "url": "<?= /* @noEscape */ $block->getUrl($block->getData('config/urlWizard'), ['id' => $block->getProduct()->getId()]) ?>",
                                "component": "Magento_Ui/js/form/components/html"
                            }
                        }
                    },
                    "<?= /* @noEscape */ $block->getData('config/form') ?>.configurableVariations": {
                        "component": "Magento_ConfigurableProduct/js/variations/variations",
                        "provider": "<?= /* @noEscape */ $block->getProvider() ?>",
                        "dataScopeVariations": "variations",
                        "dataScopeAttributes": "data.attributes",
                        "dataScopeAttributeCodes": "data.attribute_codes",
                        "dataScopeAttributesData": "data.product.configurable_attributes_data",
                        "formName": "<?= /* @noEscape */ $block->getForm() ?>",
                        "attributeSetHandler": "<?= /* @noEscape */ $block->getForm() ?>.configurable_attribute_set_handler_modal",
                        "wizardModalButtonName": "<?= /* @noEscape */ $block->getForm() ?>.configurable.configurable_products_button_set.create_configurable_products_button",
                        "wizardModalButtonTitle": "<?php echo $block->escapeHtml(__('Edit Configurations')); ?>",
                        "productAttributes": <?= /* @noEscape */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($attributes) ?>,
                        "productUrl": "<?= /* @noEscape */ $block->getUrl('catalog/product/edit', ['id' => '%id%']) ?>",
                        "variations": <?= /* @noEscape */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($productMatrix) ?>,
                        "currencySymbol": "<?= /* @noEscape */ $currencySymbol ?>",
                        "attributeSetCreationUrl": "<?= /* @noEscape */ $block->getUrl('*/product_set/save') ?>"
                    }
                }
            }
        }
    }
</script>
<script>
    require(['jquery', 'mage/apply/main'], function ($, main) {
        main.apply();
        $('.<?= /* @noEscape */ $block->getData('config/dataScope') ?>[data-role=step-wizard-dialog]').applyBindings();
        $('.<?= /* @noEscape */ $block->getData('config/dataScope') ?>[data-role=product-variations-matrix]').applyBindings();
    })
</script>
